package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.domain.db.AnalysisByDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface AnalysisByDayMapper extends BaseMapper<AnalysisByDay> {

    /**
     * 查询两个时段间的活跃用户
     * @param beginDate 开始时间
     * @param today 今天
     * @return 活跃用户数量
     */
    @Select("SELECT SUM(num_active) FROM tb_analysis_by_day WHERE record_date BETWEEN #{beginDate} AND #{today}")
    Integer selectActiveByTime(@Param("beginDate") String beginDate, @Param("today") String today);

    /**
     * 查询总用户
     * @return 总用户数
     */
    @Select("SELECT SUM(num_registered) FROM tb_analysis_by_day")
    Integer cumulativeUsers();
    /**
     * 查询每天注册人数
     */
    @Select("SELECT num_registered FROM tb_analysis_by_day WHERE record_date =#{sd}")
    Integer selectRegisterByTime (String sd);
    /**
     * 查询活跃人数
     */
    @Select("SELECT num_active FROM tb_analysis_by_day WHERE record_date =#{sd}")
    Integer selectActiveNumByTime (String sd);
    /**
     * 查询留存人数
     */
    @Select("SELECT num_retention1d FROM tb_analysis_by_day WHERE record_date =#{sd}")
    Integer selectretentionByTime (String sd);
}